package cn.faifai.desktop.view.components.menus;

import cn.faifai.desktop.events.ShowFileTaggingDialogEvent;
import cn.faifai.framework.utils.SingleEvenBus;
import javafx.scene.control.*;

/**
 * 树菜单只需要一个，菜单只需要把选中信息发布，如何操作是监听器的事，
 * 菜单无需理会，菜单只需要完成好初始化并提供菜单就好
 */
public class FileTreeItemMenu {
    private ContextMenu contextMenu;

    private FileTreeItemMenu(){
        contextMenu = new ContextMenu();

        MenuItem item1 = new MenuItem("新建文件");
        item1.setOnAction(e -> System.out.println("你选择了: " + "新建文件"));

//        MenuItem item2 = new MenuItem("关联标签");
//        item2.setOnAction(e -> {
//            System.out.println("你选择了: " + "关联标签");
//            SingleEvenBus.getInstance().post(new ShowFileTaggingDialogEvent());
//        });

        contextMenu.getItems().addAll(item1);
    }

    public static class SingletonHolder {
        private static final FileTreeItemMenu INSTANCE = new FileTreeItemMenu();


    }

    public static FileTreeItemMenu getInstance(){
        return SingletonHolder.INSTANCE;
    }

    public static ContextMenu getMenu() {
        return SingletonHolder.INSTANCE.contextMenu;
    }
}
